//
//  MineCustomBtn.m
//  jzyStudents
//
//  Created by 任辰东 on 2022/9/21.
//

#import "MineCustomBtn.h"

@interface MineCustomBtn ()

@property (nonatomic, strong) UIImageView *iconImageView;
@property (nonatomic, strong) UILabel *markLabel;

@property (nonatomic, copy) NSString *iconName;
@property (nonatomic, copy) NSString *mark;
@end

@implementation MineCustomBtn

-(instancetype)initWithIconName:(NSString *)iconName WithMark:(NSString *)mark
{
    self = [super init];
    if (self) {
        _iconName = iconName;
        _mark = mark;
        [self setupViews];
        [self setupLayout];
    }
    return self;
}

-(void)setupViews
{
    self.layer.cornerRadius = 5.0;
    self.layer.borderColor = UIColorFromHex(kColorMain).CGColor;
    self.layer.borderWidth = kOnePixel;
    [self addSubview:self.iconImageView];
    [self addSubview:self.markLabel];
    
    self.iconImageView.image = UIImageWithName(self.iconName);
    self.markLabel.text = self.mark;
}

-(void)setupLayout
{
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.centerY.equalTo(self);
        make.left.equalTo(self).offset(20);
        make.height.width.mas_equalTo(23);
    }];
    
    [self.markLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(self.iconImageView.mas_right).offset(15);
        make.right.equalTo(self).offset(-15);
        make.top.bottom.equalTo(self);
    }];
}

-(UIImageView *)iconImageView
{
    if (!_iconImageView) {
        _iconImageView = [[UIImageView alloc]init];
    }
    return _iconImageView;
}

-(UILabel *)markLabel
{
    if (!_markLabel) {
        _markLabel = [UILabel new];
        _markLabel.text = @"  ";
        _markLabel.font = UIFontSize(16);
        _markLabel.textColor = UIColorFromHex(kColorBlack);
    }
    return _markLabel;
}
@end
